// Copyright 2006 Mloofle Inc. All Rights Reserved.
// Developed via Cleanroom
import java.util.BitSet;

/**
 * Represents an "OR" Query; either child must match for the Query to match a
 * particular line.
 */
public class OrNode implements Query {

  public OrNode(Query leftHandSide, Query rightHandSide) {
    this.leftHandSide = leftHandSide;
    this.rightHandSide = rightHandSide;
  }

  public boolean matchesFilter(BitSet bloomFilter) {
    return leftHandSide.matchesFilter(bloomFilter)
        || rightHandSide.matchesFilter(bloomFilter);
  }

  public boolean matchesLineText(String lineText, CharacterAnalyzer analyzer) {
    return leftHandSide.matchesLineText(lineText, analyzer)
        || rightHandSide.matchesLineText(lineText, analyzer);
  }

  public String toString() {
    return "(" + leftHandSide.toString() + " OR " + rightHandSide.toString()
        + ")";
  }

  private final Query leftHandSide;
  private final Query rightHandSide;

}
